package com.wisnews.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wisnews.pojo.sr.entity.News;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.SQLException;

/**
 * @Description：自定义sql 执行器  生成智能推送视图
 * @Author: yuyd
 * @Email: yyd8358@foxmail.com
 * @Date: 2020/12/24 14:45
 * @Version 1.0
 */

@Mapper
public interface SqlExecuteDevice {

    @Select("${sql}")
    Object sqlExecuteDevice(@Param("sql") String Sql) throws SQLException;

    /**
     * @description: 根据对应用户的爱好视图,智能推送注册时选择的兴趣列表
     * @param:
     * @return:
     * @author yuyd
     * @date: 2021/5/3 16:50
     */
    @Select("SELECT a.news_id,a.news_title ,str_to_date(a.news_announce_time,'%Y-%m-%d %H:%i:%s') as news_announce_time,a.news_from_url ,a.news_comments,\n" +
            "            CONCAT(substring_index(a.news_content,'</p>',2),'</p>') as news_content,a.news_media,a.news_read_quantity,a.modification_time, a.create_time ," +
            " REPLACE(a.news_type,'网易首页, ','') as news_type,a.news_home_imgurl,a.news_state \n" +
            "            from ${viewName} a ORDER BY CREATE_TIME DESC ")
    IPage<News> seleteViewDate(String viewName, IPage page);

}
